package designpattern.composite;

import java.util.ArrayList;
import java.util.List;

/*
    学校
 */
public class University extends OrganizationComponent{
    //存储所有学院
    private List<OrganizationComponent> organizationComponents = new ArrayList<>();

    public University(String name, String dec) {
        super(name, dec);
    }

    public List<OrganizationComponent> getOrganizationComponents() {
        return organizationComponents;
    }

    public void setOrganizationComponents(List<OrganizationComponent> organizationComponents) {
        this.organizationComponents = organizationComponents;
    }

    @Override
    public void add(OrganizationComponent organizationComponent) {
        organizationComponents.add(organizationComponent);
    }

    @Override
    public void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }

    @Override
    public void print() {
        System.out.println("学校名字:"+getName()+",学校描述:"+getDec());
        for(OrganizationComponent organizationComponent: organizationComponents){
            organizationComponent.print();
        }
    }
}
